package mx.itschapala.dsw2.llantas.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.dsw2.llantas.modelo.Articulo;

/**
 *
 * @author VENUMLEO
 */
@Stateless
public class Articulodao extends Abstractdao<Articulo> implements ArticulodaoLocal {
    @PersistenceContext(unitName = "llantas-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public Articulodao() {
        super(Articulo.class);
    }
     public boolean findDuplicity(Articulo article) {
      // selecionar consulta
        Query q=em.createNamedQuery("Autor.findDuplicity");
       //poner parametros
        q.setParameter("nombre", article.getMarca());
        q.setParameter("apellidoPaterno", article.getRodado());
        q.setParameter("apellidoMaterno", article.getTipollanta());
        //ejecutar la consulta
        return !q.getResultList().isEmpty();
    }
    
}
